﻿Type.registerNamespace('RibbonCustomization');
var _samplePageComponent;

RibbonCustomization.SamplePageComponent = function () {
    RibbonCustomization.SamplePageComponent.initializeBase(this);
}

RibbonCustomization.SamplePageComponent.init = function () {
    if (_samplePageComponent == null || _samplePageComponent == 'undefined') {
        _samplePageComponent = new RibbonCustomization.SamplePageComponent();
        SP.Ribbon.PageManager.get_instance().addPageComponent(_samplePageComponent);
    }
    return _samplePageComponent;
}

RibbonCustomization.SamplePageComponent.prototype =
{
    init: function () {
    },

    isFocusable: function () {
        return true;
    },

    receiveFocus: function () {
        return true;
    },

    yieldFocus: function () {
        return true;
    },

    getFocusedCommands: function () {
        return new Array();
    },

    getGlobalCommands: function () {
        var commands = new Array();
        Array.add(commands, 'Ribbon.TabWithControlsAndCommands');
        Array.add(commands, 'Ribbon.TabWithControlsAndCommands.DemoGroup');
        Array.add(commands, 'Ribbon.TabWithControlsAndCommands.DemoGroup.MyFirstButton');
        Array.add(commands, 'Ribbon.TabWithControlsAndCommands.DemoGroup.MySecondButton');
        Array.add(commands, 'Ribbon.TabWithControlsAndCommands.DemoGroup.MyThirdButton');
        return commands;
    },

    canHandleCommand: function (commandId) {
        if (commandId == 'Ribbon.TabWithControlsAndCommands' || 
            commandId == 'Ribbon.TabWithControlsAndCommands.DemoGroup' ||
            commandId == 'Ribbon.TabWithControlsAndCommands.DemoGroup.MyFirstButton' ||
            commandId == 'Ribbon.TabWithControlsAndCommands.DemoGroup.MySecondButton' ||
            commandId == 'Ribbon.TabWithControlsAndCommands.DemoGroup.MyThirdButton') {
            return true;
        }
        return false;
    },

    handleCommand: function (commandId, properties, sequence) {
        alert(commandId);
        return true;
    }
}

RibbonCustomization.SamplePageComponent.registerClass('RibbonCustomization.SamplePageComponent', SP.Ribbon.WebPartComponent);
if (typeof (Sys) != "undefined" && Sys && Sys.Application) {
    Sys.Application.notifyScriptLoaded();
}
NotifyScriptLoadedAndExecuteWaitingJobs("SamplePageComponent.js");